package com.revenco.bi.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.revenco.bi.controller.basecontroller.AbstractUserAwareController;
import com.revenco.bi.model.TnTableInfo;
import com.revenco.bi.service.TnTableInfoService;

/**
 * @author LingJun
 * @version $Revision:1.0.0, 2014年1月6日 下午7:40:39
 */
@Controller
public class TnTableInfoController extends AbstractUserAwareController {
	@Autowired
	private TnTableInfoService tnTableInfoService;

	@RequestMapping(value = "/getTables")
	@ResponseBody
	public List<TnTableInfo> TnTableInfoList() throws Exception {
		return tnTableInfoService.getAll();
	}

	/**
	 * 根据表name, 获取表信息
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getTreeNodes")
	@ResponseBody
	public List<TnTableInfo> getTreeNodes(@RequestParam("changeId") String id)
			throws Exception {
		List<TnTableInfo> tables = tnTableInfoService.getTableByName(id);
		log.info("table name: {}, Tables size: {}", id, tables.size());

		return tables;
	}
}
